package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

@Setter@Getter
public class Strategy extends BaseDomain{

    public static final Integer STATE_NOMAL = 0; //正常
    public static final Integer STATE_DISABLE = 1; //禁用
    public static final Integer STATE_COMMEND = 2; //推荐

    public static final Integer COLLECT_TEMP = 0; //未收藏
    public static final Integer COLLECT_RELEASE = 1; //已经收藏

    private String title;

    private String subTitle;

    private String coverUrl;

    private Integer state = STATE_NOMAL;

    private Region place;

    private Integer collect = COLLECT_TEMP;      //收藏状态：是否收藏

    private Integer strategyNum;  //此攻略收藏数量

    private User user;

    public String getStateName(){
        String msg = "正常";
        if(state == STATE_DISABLE){
            msg = "禁用";
        }else if(state == STATE_COMMEND){
            msg = "推荐";
        }
        return msg;
    }

    public String getCollectName(){
        String msg = "未收藏";
        if (collect == COLLECT_RELEASE){
            msg = "已经收藏";
        }
        return msg;
    }

    public String getJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("title",title);
        map.put("subTitle",subTitle);
        map.put("coverUrl",coverUrl);
        map.put("state",state);
        if(place != null){
            map.put("placeId",place.getId());
        }
        return JSONUtil.toJSONString(map);
    }

}